﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

#include "GbmpDefines.h"
#include "IDbObject.h"
#include "GcmpModelInterface.h"

namespace gcmp {

    class IDocument;
    class IElement;
    class IParameter;

    /// \brief 参数集
    FINAL_INTERFACE class GCMP_MODEL_INTERFACE_EXPORT IPropertyCollection : public IDbObject
    {
        DEFINE_CAST_DERIVED(gcmp::IPropertyCollection, gcmp::IDbObject)

    public:
        /// \brief 创建参数集
        /// \param pDocument 参数集所属文档
        /// \param pOwnerElement 参数集所属Element
        /// \return 新创建的参数集
        static OwnerPtr<IPropertyCollection> Create(const std::wstring& name);

        /// \brief 获取参数集名称
        /// \return 获取的参数集名称
        virtual const std::wstring & GetName() const = 0;

        /// \brief 往参数集中增加参数
        /// \param opParameter 要增加的参数
        /// \return 成功返回true，失败返回false
        virtual bool AddParameter(OwnerPtr<IParameter> opParameter) = 0;

        /// \brief 获取参数集中的所有参数
        /// \return 参数集中的所有参数
        virtual std::vector<const IParameter*> GetAllParameters() const = 0;
    };

    /// \brief 参数子部件
    FINAL_INTERFACE class GCMP_MODEL_INTERFACE_EXPORT ISubComponentPropertyCollection : public IDbObject
    {
        DEFINE_CAST_DERIVED(gcmp::ISubComponentPropertyCollection, gcmp::IDbObject)
    public:
        /// \brief 创建一个参数子部件
        /// \return 新创建的参数子部件
        static OwnerPtr<ISubComponentPropertyCollection> Create(const std::wstring& name);

        /// \brief 获取参数子部件名称
        /// \return 获取的参数子部件名称
        virtual const std::wstring & GetName() const = 0;

        /// \brief 往参数子部件中增加参数集
        /// \param opPropertyCollection 要增加的参数集
        /// \return 成功返回true，失败返回false
        virtual bool AddPropertyCollection(OwnerPtr<IPropertyCollection> opPropertyCollection) = 0;

        /// \brief 获取该参数子部件中直属的参数集
        /// \return 获取的参数子部件直属的参数集
        virtual std::vector<const IPropertyCollection*> GetPropertyCollections() const = 0;

        /// \brief 往参数子部件中增加嵌套的参数子部件
        /// \param opSubComponentPropertyCollection 要增加的嵌套的参数子部件
        /// \return 成功返回true，失败返回false
        virtual bool AddSubComponentPropertyCollection(OwnerPtr<ISubComponentPropertyCollection> opSubComponentPropertyCollection) = 0;

        /// \brief 获取该参数子部件中直属的嵌套参数子部件
        /// \param 获取的参数子部件中直属的嵌套参数子部件
        /// \return 成功返回true，失败返回false
        virtual std::vector<const ISubComponentPropertyCollection*> GetSubComponentPropertyCollections() const = 0;

        /// \brief 克隆参数子部件
        /// \return 克隆得到的参数子部件
        virtual OwnerPtr<ISubComponentPropertyCollection> Clone() const = 0;
    };
}


